package main

import (
	"fishDemo/Handler"
	"fishDemo/controller"
	"github.com/gin-gonic/gin"
	"net/http"
)

func CollecRouter(r *gin.Engine) *gin.Engine {

	api := r.Group("/api")
	{
		// api 路由组内部再嵌套一个路由组 user
		auth := api.Group("/auth")
		{
			//登录注册操作
			auth.GET("/register", controller.Register)
			auth.POST("/login", controller.Login)
			auth.POST("/register", controller.Register)
		}
		buy := api.Group("/buy", Handler.CommonPerson())
		{
			//买鱼
			buy.GET("/buyFish", controller.Register)
		}
	}
	//	无限制的页面跳转的
	r.GET("/index", Handler.MyHandler(), func(context *gin.Context) {
		context.HTML(http.StatusOK, "index.html", gin.H{"msg": "go -> html json source"})
	})
	r.GET("/login", func(context *gin.Context) {
		context.HTML(http.StatusOK, "login.html", gin.H{"msg": "go -> html json source"})
	})
	r.GET("/register", func(context *gin.Context) {
		context.HTML(http.StatusOK, "register.html", gin.H{"msg": "go -> html json source"})
	})
	//接下来的两个是： rabbitMq测试示例
	r.GET("/rrtest", controller.TestRabbitMqGet)
	r.GET("/rrtestRec", controller.TestRabbitMqGetMess)

	return r
}
